﻿@model IEnumerable<Model.ViewModel.CheckoutList>
@foreach(var g in Model){
@g.CheckoutTime<br />
}
 <!------page-------->
<div class="container-fluid">
    <nav>
        <ul class="pagination pagination-sm" id="Page">
            @*<li><a href="#">&laquo;</a></li>
                <li><a href="#">1</a></li>
                <li><a href="#">2</a></li>
                <li><a href="#">3</a></li>
                <li><a href="#">4</a></li>
                <li><a href="#">5</a></li>
                <li><a href="#">&raquo;</a></li>*@
        </ul>
    </nav>
</div>
<script type="text/javascript">
    $(function () {
        
        var total =1500;
        var Currentpage;
        var pagesize = 15;
        var HttpAddress = "Query\CheckoutList"
        if (Currentpage == null)
            Currentpage = 1;

        var allpage = 0;//是分多少页
        var next = 0;
        var pre = 0;
        var startcount = 0;
        var endcount = 0;
        var pagestr = "";

        if (Currentpage < 1) { Currentpage = 1; }
        //计算总页数allpage赋值
        if (pagesize != 0) {
            allpage = Math.floor(total / pagesize);//分页计算
            allpage = ((total % pagesize) != 0 ? allpage + 1 : allpage);//一页不够的多做一页
            allpage = (allpage == 0 ? 1 : allpage);
        }
        //next = Currentpage + 1;
        //pre = Currentpage - 1;

        startcount = (Currentpage + 5) > allpage ? allpage - 9 : Currentpage - 4;//中间页起始序号
        //中间页终止序号
        endcount = Currentpage < 5 ? 10 : Currentpage + 5;
        console.log(Currentpage,startcount, endcount);
        if (startcount < 1) { startcount = 1; } //为了避免输出的时候产生负数，设置如果小于1就从序号1开始
        if (allpage < endcount) { endcount = allpage; } //页码+5的可能性就会产生最终输出序号大于总页码，那么就要将其控制在页码数之内
       
        pagestr += Currentpage == 1 ? "<li><a href=\" \"> &laquo; </a></li>" : "<li><a href=\"# \" onclick='opo(" + (Currentpage - 1) + ")'> &laquo; </a> </li>";

        //中间页处理，这个增加时间复杂度，减小空间复杂度
        for (var i = startcount; i <= endcount; i++) {
          

            pagestr += Currentpage == i ? "<li class=\"active\"><a href=\"\">" + i + " <span class=\"sr-only\">(current)</span></a></li>" : "<li><a href='#' onclick='opo(" + i + ")'>" + i + "</a></li>";
        }
        pagestr += Currentpage != allpage ? "<li><a href=\"# \" onclick='opo(" + (Currentpage + 1) + ")'> &raquo; </a> </li>" : "<li><a href=\" \"> &raquo;</a></li>";

        $("#Page").html(pagestr);
    })

    function Fenye() {

    }
    function opo(ii)
    {
        var k = ii;
        Currentpage = ii;
        
        var total = 1500;
        var Currentpage;
        var pagesize =15;
        var HttpAddress = "Query\CheckoutList"
        if (Currentpage == null)
            Currentpage = 1;

        var allpage = 0;//是分多少页
        var next = 0;
        var pre = 0;
        var startcount = 0;
        var endcount = 0;
        var pagestr = "";
        
        if (Currentpage < 1) { Currentpage = 1; }
        //计算总页数allpage赋值
        if (pagesize != 0) {
            allpage = Math.floor(total / pagesize);//分页计算
            allpage = ((total % pagesize) != 0 ? allpage + 1 : allpage);//一页不够的多做一页
            allpage = (allpage == 0 ? 1 : allpage);
        }
        //next = Currentpage + 1;
        //pre = Currentpage - 1;
        startcount = (Currentpage + 5) > allpage ? allpage - 9 : Currentpage - 4;//中间页起始序号
        //中间页终止序号
        endcount = Currentpage < 5 ? 10 : Currentpage + 5;
        if (startcount < 1) { startcount = 1; } //为了避免输出的时候产生负数，设置如果小于1就从序号1开始
        if (allpage < endcount) { endcount = allpage; } //页码+5的可能性就会产生最终输出序号大于总页码，那么就要将其控制在页码数之内
     
        pagestr += Currentpage == 1 ? "<li><a href=\" \"> &laquo; </a></li>" : "<li><a href=\"# \" onclick='opo(" + (Currentpage-1) + ")'> &laquo; </a> </li>";
        
        //中间页处理，这个增加时间复杂度，减小空间复杂度
        for (var i = startcount; i <= endcount; i++) {
            //pagestr += Currentpage == i ? "<li class=\"active\"><span>" + i + "<span class=\"sr-only\">(current)</span></span></li>" : "<li><a href=\"" + HttpAddress + "?Currentpage=" + i + "</a></li>";
            //pagestr += Currentpage == i ? "<li class=\"active\"><span>" + i + "<span class=\"sr-only\">(current)</span></span></li>" : "<li><a href=\"" + HttpAddress + "?Currentpage=" + i + "</a></li>";
            
            pagestr +=Currentpage == i ?"<li class=\"active\"><a href=\"\">"+i+" <span class=\"sr-only\">(current)</span></a></li>":"<li><a href='#' onclick='opo(" + i + ")'>" + i + "</a></li>";
        }
       
        pagestr += Currentpage != allpage ? "<li><a href=\"# \" onclick='opo(" + (Currentpage + 1) + ")'> &raquo; </a> </li>" : "<li><a href=\" \"> &raquo;</a></li>";

        $("#Page").html(pagestr);
    }

</script>

@*<script src="~/Scripts/pagination.js"></script>
<script type="text/javascript">
    var total = '@ViewData["CheckoutTotalPage"]';
    console.log(total);
    var pageIndex = 0;     //页面索引初始值
    var pageSize = 10;     //每页显示条数初始化，修改显示条数，修改这里即可
   
    InitTable(1);    //Load事件，初始化表格数据，页面索引为0（第一页）
    //分页，PageCount是总条目数，这是必选参数，其它参数都是可选
    $("#Pagination").pagination(total, {
        callback: PageCallback,  //PageCallback() 为翻页调用次函数。
        prev_text: "« 上一页",
        next_text: "下一页 »",
        items_per_page: pageSize,
        num_edge_entries: 2,       //两侧首尾分页条目数
        num_display_entries: 6,    //连续分页主体部分分页条目数
        current_page: pageIndex   //当前页索引
    });
    //翻页调用
    function PageCallback(index, jq) {

        InitTable(index);
    }
        //请求数据
        function InitTable(pageIndex) {

            $.ajax({
                type: "POST",
                // dataType: "text",
                url: 'Query/CheckoutList',      //提交到一般处理程序请求数据
                data: "pageIndex=" + (pageIndex) + "&pageSize=" + pageSize,          //提交两个参数：pageIndex(页面索引)，pageSize(显示条数)
                success: function (msg) {


                 


                }
            });

        }


</script>*@